﻿using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections;

namespace P2P.Client.UI.Features.Server
{
    public partial class ServerInfoViewModel : ObservableObject
    {
        [ObservableProperty]
        [property: Category("Numbers"), DisplayName("ID")]
        private int? _id = null;

        [ObservableProperty]
        [property: Category("Text"), DisplayName("服务器名称")]
        private string? _serverName;

        [ObservableProperty]
        [property: Category("Text"), DisplayName("IP")]
        private string? _ip = null;

        [ObservableProperty]
        [property: Category("Numbers"), DisplayName("端口")]
        private int? _port = null;

        [ObservableProperty]
        [property: Category("Text"), DisplayName("描述")]
        private string? _desc = null;

        [ObservableProperty]
        [property: Category("Text"), DisplayName("服务器版本")]
        private string? _version = null;

        [ObservableProperty]
        [property: Category("Numbers"), DisplayName("Ping")]
        private long? _ping = null;

        [ObservableProperty]
        [property: Category("Numbers"), DisplayName("用户数")]
        private int? _userCount = null;

        [ObservableProperty]
        [property: Category("Numbers"), DisplayName("最大用户数")]
        private int? _maxUserCount = null;

        [ObservableProperty]
        [property: Category("Text"), DisplayName("连接状态")]
        private string? _connectState = null;

        [ObservableProperty] private int? _selectedPriorityContent;
        public AvaloniaList<Item> PriorityList { get; } = new();

        public class Item 
        {
            public string? Text { get; set; }
            public int? Value { get; set; }
        }

        public ServerInfoViewModel()
        {
            PriorityList.Add(new() { Value = 1, Text = "低" });
            PriorityList.Add(new() { Value = 2, Text = "普通" });
            PriorityList.Add(new() { Value = 3, Text = "高" });
            SelectedPriorityContent = PriorityList.First().Value;
        }
    }
}
